import { RouteObject, Navigate } from 'react-router-dom';
import { lazy } from 'react';
// import Discover from "@/views/discover";
// import Mine from "@/views/mine";
// import Focus from "@/views/focus";
// import Download from "@/views/download";

// 路由 懒加载（分包)  优化性能
const Discover = lazy(() => import('@/views/discover'));
const Recommended = lazy(() => import('@/views/discover/c-components/recommended'));
const Ranking = lazy(() => import('@/views/discover/c-components/ranking'));
const Songs = lazy(() => import('@/views/discover/c-components/songs'));
const Redio = lazy(() => import('@/views/discover/c-components/redio'));
const Singers = lazy(() => import('@/views/discover/c-components/singers'));
const Releases = lazy(() => import('@/views/discover/c-components/releases'));

const Mine = lazy(() => import('@/views/mine'));
const Focus = lazy(() => import('@/views/focus'));
const Download = lazy(() => import('@/views/download'));
const Detail = lazy(() => import('@/views/detail'));

const routes: RouteObject[] = [
  {
    path: '/',
    element: <Navigate to="/discover" />, // Navigate 重定向
  },
  {
    path: '/discover',
    element: <Discover />,
    children: [
      {
        path: '/discover',
        element: <Navigate to="/discover/recommended" />, // Navigate 重定向
      },
      {
        path: '/discover/recommended',
        element: <Recommended />,
      },
      {
        path: '/discover/ranking',
        element: <Ranking />,
      },
      {
        path: '/discover/songs',
        element: <Songs />,
      },
      {
        path: '/discover/radio',
        children: [
          {
            path: '',
            element: <Redio />,
          },
          {
            path: 'categroy',
            element: <Redio />,
          },
        ],
      },
      {
        path: '/discover/singers',
        element: <Singers />,
      },
      {
        path: '/discover/release',
        element: <Releases />,
      },
    ],
  },
  {
    path: '/mine',
    element: <Mine />,
  },
  {
    path: '/focus',
    element: <Focus />,
  },
  {
    path: '/download',
    element: <Download />,
  },
  {
    path: '/detail',
    element: <Detail />,
  },
];

export default routes;
